package dataStructure.xmg1.a13;

import dataStructure.xmg1.a13.map.HashMap;
import dataStructure.xmg1.a13.map.Map;
import dataStructure.xmg1.a13.model.Key;
import dataStructure.xmg1.a13.model.Person;
import dataStructure.xmg1.a13.model.SubKey1;
import dataStructure.xmg1.a13.model.SubKey2;

/**
 * @author: vince_zww
 * @date: 2021/6/13 12:02
 * @desceription:
 */
public class Main {



    public static void main(String[] args) {
//        test01();
//        test02();
//        test03();
//        test04();
//        test05();
//        test06();



    }

    private static void test06(HashMap<Object,Integer> map) {
        for (int i = 1; i <= 20; i++) {
            map.put(new Key(i), i);
        }
        for (int i = 5; i <= 7; i++) {
            map.put(new Key(i), i + 5);
        }


    }




    private static void test05() {
        SubKey1 key1 = new SubKey1(1);
        SubKey2 key2 = new SubKey2(2);

        HashMap<Object, Integer> map = new HashMap<>();

        map.put(key1, 1);
        map.put(key2, 2);

        System.out.println(key1.equals(key2));
    }

    private static void test04() {
        HashMap<Object, Integer> map = new HashMap<>();
        for (int i = 1; i <=18; i++) {
            map.put(new Key(i), i);
        }
        map.put(new Key(19),100);
//        System.out.println(map.size());
//        System.out.println(map.get(new Key(15)));
        map.print();
    }

    private static void test03() {
        HashMap<Object, Integer> map = new HashMap<>();
        for (int i = 1; i <=19; i++) {
            map.put(new Key(i), i);
        }
        map.print();

//        map.traversal(new Map.Visitor<Object, Integer>() {
//            @Override
//            public boolean visit(Object key, Integer value) {
//                System.out.println(key+"_"+value);
//                return false;
//            }
//        });
        System.out.println(map.get(new Key(1)));
    }


    private static void test02() {
        Person p1 = new Person(10, 1.67f, "jack");
        Person p2 = new Person(10, 1.67f, "jack");

        Map<Object,Integer> map =new HashMap<>();
        map.put(p1, 1);
        map.put(p2, 2);
        map.put("jack", 3);

        System.out.println(map.size());
        System.out.println(map.get("jack"));
        System.out.println(map.remove("jack"));
        System.out.println(map.size());

        map.traversal(new Map.Visitor<Object, Integer>() {
            @Override
            public boolean visit(Object key, Integer value) {
                System.out.println(key + "_" + value);
                return false;
            }
        });
    }

    private static void test01() {
        int i = 10;
        System.out.println(31 * i);
        System.out.println((i << 5) - i);


        String string = "jack";
        int len=string.length();
        int hashCode = 0;
        for (int j = 0; j < len; j++) {
            char c = string.charAt(j);
            hashCode = hashCode * 31 + c;
        }

        System.out.println(hashCode);
        System.out.println(string.hashCode());
    }


}
